<template>
  <el-col :span="8">
    <el-menu
      default-active="1"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose">
      <el-menu-item index="1" v-on:click="signInVisible = true">
        <i class="el-icon-alarm-clock"></i>
        <span slot="title">每日签到</span>
      </el-menu-item>
      <el-menu-item index="2" v-on:click="linkto('/Find')">
        <i class="el-icon-star-on"></i>
        <span slot="title">问卷精选</span>
      </el-menu-item>
      <el-menu-item index="3" v-on:click="linkto('/Me/Score')">
        <i class="el-icon-postcard"></i>
        <span slot="title" >积分商城</span>
      </el-menu-item>
      <el-menu-item index="4" @click.native="copyInvitelink()">
        <i class="el-icon-chat-round"></i>
        <span slot="title" >邀请好友</span>
      </el-menu-item>
    </el-menu>
    <el-dialog title="每日签到" :visible.sync="signInVisible" :before-close="Close">
      <SignIn></SignIn>
    </el-dialog>
  </el-col>

</template>

<script>
  import SignIn from './SignIn'
export default {
        name: 'Side-Bar',
        components: {
          SignIn
        },
        data(){
          return {signInVisible:false};
        },
        methods: {
            Close(){
              this.signInVisible = false
            },
            handleOpen (key, keyPath) {
                console.log(key, keyPath)
            },
            handleClose (key, keyPath) {
              this.signInVisiable = false
                console.log(key, keyPath)
            },
            copyInvitelink(){
              var this_ = this;
              //invitecode为邀请码，没有可以删去
              let invitelink = location.href.replace(this.$route.path,'') + "/register?invitecode=";
              this.$copyText(invitelink).then(
                  this.$message({
                    message: `复制成功！`,
                    type: 'success'
                  }),
                function(e) {
                  console.log(this_.$t("my.copeErr"));
                }
              );
            },
        linkto(url){
            this.$router.push(url);
        }

}
    }
</script>

<style scoped>

</style>
